<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var sum = "1234567890"
        var num = ""
        var max = 0
        for (i = 0; i < sum.length - 4; i++) {
            num = sum.substr(i, 5)
            if (max < num) {
                max = num
            }

        }
        console.log(max)
    </script>
</body>

</html>